Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

feature/map/src/commonMain/kotlin/org/meshtastic/feature/map/component/NodeTrackLayers.kt 4607c3f223b07c78d3b7e58ea46f4bb9d67b04c9 (4607c3f2) Text, 4.41 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.feature.map.component

Tff7b72import T7ee787androidx.compose.runtime.Composable
Tff7b72import T7ee787androidx.compose.runtime.remember
Tff7b72import T7ee787androidx.compose.ui.graphics.Color
Tff7b72import T7ee787androidx.compose.ui.unit.dp
Tff7b72import T7ee787kotlinx.serialization.json.jsonPrimitive
Tff7b72import T7ee787org.maplibre.compose.expressions.dsl.asString
Tff7b72import T7ee787org.maplibre.compose.expressions.dsl.const
Tff7b72import T7ee787org.maplibre.compose.expressions.dsl.eq
Tff7b72import T7ee787org.maplibre.compose.expressions.dsl.feature
Tff7b72import T7ee787org.maplibre.compose.expressions.dsl.interpolate
Tff7b72import T7ee787org.maplibre.compose.expressions.dsl.linear
Tff7b72import T7ee787org.maplibre.compose.expressions.value.LineCap
Tff7b72import T7ee787org.maplibre.compose.expressions.value.LineJoin
Tff7b72import T7ee787org.maplibre.compose.layers.CircleLayer
Tff7b72import T7ee787org.maplibre.compose.layers.LineLayer
Tff7b72import T7ee787org.maplibre.compose.sources.GeoJsonData
Tff7b72import T7ee787org.maplibre.compose.sources.GeoJsonOptions
Tff7b72import T7ee787org.maplibre.compose.sources.rememberGeoJsonSource
Tff7b72import T7ee787org.maplibre.compose.util.ClickResult
Tff7b72import T7ee787org.meshtastic.feature.map.util.lineProgress
Tff7b72import T7ee787org.meshtastic.feature.map.util.positionsToLineString
Tff7b72import T7ee787org.meshtastic.feature.map.util.positionsToPointFeatures

Tff7b72private Tff7b72val Te6edf3TrackColor Tff7b72= Te6edf3ColorTb4b4b4(T79c0ff0Te6edf3xFF2196F3Tb4b4b4)
Tff7b72private Tff7b72val Te6edf3TrackColorFaded Tff7b72= Te6edf3ColorTb4b4b4(T79c0ff0Te6edf3x662196F3Tb4b4b4)
Tff7b72private Tff7b72val Te6edf3SelectedPointColor Tff7b72= Te6edf3ColorTb4b4b4(T79c0ff0Te6edf3xFFF44336Tb4b4b4)
Tff7b72private Tff7b72const Tff7b72val Te6edf3SELECTED_OPACITY Tff7b72= T79c0ff0.9f

T8b949e/**
* Renders a position history track as a line with marker points. Replaces the Google Maps Polyline + MarkerComposable
* and OSMDroid Polyline overlay implementations.
*/
Tf0883e@Composable
Tff7b72internal Tff7b72fun Td2a8ffNodeTrackLayersTb4b4b4(
Te6edf3positionsTb4b4b4: Te6edf3ListTff7b72<Te6edf3orgTb4b4b4.Te6edf3meshtasticTb4b4b4.Te6edf3protoTb4b4b4.Te6edf3PositionTff7b72>Tb4b4b4,
Te6edf3selectedPositionTimeTb4b4b4: Tffa657Int? Tff7b72= Tff7b72nullTb4b4b4,
Te6edf3onSelectPositionTb4b4b4: Tb4b4b4(Tb4b4b4(Tffa657IntTb4b4b4) Tff7b72-Tff7b72> Tffa657UnitTb4b4b4)Tff7b72? Tff7b72= Tff7b72nullTb4b4b4,
Tb4b4b4) Tb4b4b4{
Tff7b72if Tb4b4b4(Te6edf3positionsTb4b4b4.Te6edf3size Tff7b72< T79c0ff2Tb4b4b4) Tff7b72return

T8b949e// Line track source
Tff7b72val Te6edf3lineFeatureCollection Tff7b72= Te6edf3rememberTb4b4b4(Te6edf3positionsTb4b4b4) Tb4b4b4{ Te6edf3positionsToLineStringTb4b4b4(Te6edf3positionsTb4b4b4) Tb4b4b4}

Tff7b72val Te6edf3lineSource Tff7b72=
Te6edf3rememberGeoJsonSourceTb4b4b4(
Te6edf3data Tff7b72= Te6edf3GeoJsonDataTb4b4b4.Te6edf3FeaturesTb4b4b4(Te6edf3lineFeatureCollectionTb4b4b4)Tb4b4b4,
Te6edf3options Tff7b72= Te6edf3GeoJsonOptionsTb4b4b4(Te6edf3lineMetrics Tff7b72= Tff7b72trueTb4b4b4)Tb4b4b4,
Tb4b4b4)

T8b949e// Track line with gradient (oldest positions faded → newest positions vivid)
Te6edf3LineLayerTb4b4b4(
Te6edf3id Tff7b72= Ta5d6ff"Ta5d6ffnode-track-lineTa5d6ff"Tb4b4b4,
Te6edf3source Tff7b72= Te6edf3lineSourceTb4b4b4,
Te6edf3width Tff7b72= Te6edf3constTb4b4b4(T79c0ff3.Te6edf3dpTb4b4b4)Tb4b4b4,
Te6edf3gradient Tff7b72= Te6edf3interpolateTb4b4b4(Te6edf3linearTb4b4b4(Tb4b4b4)Tb4b4b4, Te6edf3lineProgressTb4b4b4(Tb4b4b4)Tb4b4b4, T79c0ff0 Te6edf3to Te6edf3constTb4b4b4(Te6edf3TrackColorFadedTb4b4b4)Tb4b4b4, T79c0ff1 Te6edf3to Te6edf3constTb4b4b4(Te6edf3TrackColorTb4b4b4)Tb4b4b4)Tb4b4b4,
Te6edf3cap Tff7b72= Te6edf3constTb4b4b4(Te6edf3LineCapTb4b4b4.Te6edf3RoundTb4b4b4)Tb4b4b4,
Te6edf3join Tff7b72= Te6edf3constTb4b4b4(Te6edf3LineJoinTb4b4b4.Te6edf3RoundTb4b4b4)Tb4b4b4,
Tb4b4b4)

T8b949e// Position marker points
Tff7b72val Te6edf3pointFeatureCollection Tff7b72= Te6edf3rememberTb4b4b4(Te6edf3positionsTb4b4b4) Tb4b4b4{ Te6edf3positionsToPointFeaturesTb4b4b4(Te6edf3positionsTb4b4b4) Tb4b4b4}

Tff7b72val Te6edf3pointsSource Tff7b72= Te6edf3rememberGeoJsonSourceTb4b4b4(Te6edf3data Tff7b72= Te6edf3GeoJsonDataTb4b4b4.Te6edf3FeaturesTb4b4b4(Te6edf3pointFeatureCollectionTb4b4b4)Tb4b4b4)

Te6edf3CircleLayerTb4b4b4(
Te6edf3id Tff7b72= Ta5d6ff"Ta5d6ffnode-track-pointsTa5d6ff"Tb4b4b4,
Te6edf3source Tff7b72= Te6edf3pointsSourceTb4b4b4,
Te6edf3radius Tff7b72= Te6edf3constTb4b4b4(T79c0ff5.Te6edf3dpTb4b4b4)Tb4b4b4,
Te6edf3color Tff7b72= Te6edf3constTb4b4b4(Te6edf3TrackColorTb4b4b4)Tb4b4b4,
Te6edf3strokeWidth Tff7b72= Te6edf3constTb4b4b4(T79c0ff1.Te6edf3dpTb4b4b4)Tb4b4b4,
Te6edf3strokeColor Tff7b72= Te6edf3constTb4b4b4(Te6edf3ColorTb4b4b4.Te6edf3WhiteTb4b4b4)Tb4b4b4,
Te6edf3onClick Tff7b72= Tb4b4b4{ Te6edf3features Tff7b72-Tff7b72>
Tff7b72val Te6edf3time Tff7b72= Te6edf3featuresTb4b4b4.Te6edf3firstOrNullTb4b4b4(Tb4b4b4)Tff7b72?.Te6edf3propertiesTff7b72?.Te6edf3getTb4b4b4(Ta5d6ff"Ta5d6fftimeTa5d6ff"Tb4b4b4)Tff7b72?.Te6edf3jsonPrimitiveTff7b72?.Te6edf3contentTff7b72?.Te6edf3toIntOrNullTb4b4b4(Tb4b4b4)
Tff7b72if Tb4b4b4(Te6edf3time Tff7b72!Tff7b72= Tff7b72null Tff7b72&Tff7b72& Te6edf3onSelectPosition Tff7b72!Tff7b72= Tff7b72nullTb4b4b4) Tb4b4b4{
Te6edf3onSelectPositionTb4b4b4(Te6edf3timeTb4b4b4)
Te6edf3ClickResultTb4b4b4.Te6edf3Consume
Tb4b4b4} Tff7b72else Tb4b4b4{
Te6edf3ClickResultTb4b4b4.Te6edf3Pass
Tb4b4b4}
Tb4b4b4}Tb4b4b4,
Tb4b4b4)

T8b949e// Highlight selected position
Tff7b72if Tb4b4b4(Te6edf3selectedPositionTime Tff7b72!Tff7b72= Tff7b72nullTb4b4b4) Tb4b4b4{
Te6edf3CircleLayerTb4b4b4(
Te6edf3id Tff7b72= Ta5d6ff"Ta5d6ffnode-track-selectedTa5d6ff"Tb4b4b4,
Te6edf3source Tff7b72= Te6edf3pointsSourceTb4b4b4,
Te6edf3filter Tff7b72= Te6edf3featureTff7b72[Ta5d6ff"Ta5d6fftimeTa5d6ff"Tff7b72]Tb4b4b4.Te6edf3asStringTb4b4b4(Tb4b4b4) Te6edf3eq Te6edf3constTb4b4b4(Te6edf3selectedPositionTimeTb4b4b4.Te6edf3toStringTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4,
Te6edf3radius Tff7b72= Te6edf3constTb4b4b4(T79c0ff1T79c0ff0.Te6edf3dpTb4b4b4)Tb4b4b4,
Te6edf3color Tff7b72= Te6edf3constTb4b4b4(Te6edf3SelectedPointColorTb4b4b4)Tb4b4b4, T8b949e// Red
Te6edf3strokeWidth Tff7b72= Te6edf3constTb4b4b4(T79c0ff2.Te6edf3dpTb4b4b4)Tb4b4b4,
Te6edf3strokeColor Tff7b72= Te6edf3constTb4b4b4(Te6edf3ColorTb4b4b4.Te6edf3WhiteTb4b4b4)Tb4b4b4,
Te6edf3opacity Tff7b72= Te6edf3constTb4b4b4(Te6edf3SELECTED_OPACITYTb4b4b4)Tb4b4b4,
Tb4b4b4)
Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.07s